#include "testlib.h"
#include <stdio.h>
#define N 50100
long long x[3*N], y[3*N];
int main(int argc, char * argv[])
{
    registerTestlibCmd(argc, argv);
    int n, i, k;
	n=inf.readInt();
	for(i=0; i<3*n-1; i++)
		x[i]=ans.readLong();
	for(i=2*n-1; i<3*n-1; i++)
		if(x[i]>50) quitf(_fail, "height is greater than 50");
	for(i=0; i<3*n-1; i++)
	{
		if(ouf.seekEof()) break;
		y[i]=ouf.readLong();
	}
	k=i;
	if(k==n)
	{
		for(i=0; i<n && y[i]==x[2*n-1+i]; i++);
		if(i==n) quitf(_ok, "Treap");
	}
	if(k==2*n-1)
	{
		for(i=0; i<2*n-1 && y[i]==x[i]; i++);
		if(i==2*n-1) quitf(_ok, "FFT");
	}
	if(k==3*n-1)
	{
		for(i=0; i<3*n-1 && y[i]==x[i]; i++);
		if(i==3*n-1) quitf(_ok, "FFT and Treap");
		for(i=0; i<3*n-1 && y[i]==x[(i+2*n-1)%(3*n-1)]; i++);
		if(i==3*n-1) quitf(_ok, "Treap and FFT");
	}
	if(k==n) quitf(_wa, "wrong Treap");
	if(k==2*n-1) quitf(_wa, "wrong FFT");
	if(k==3*n-1) quitf(_wa, "wrong FFT and Treap");
	quitf(_pe, "output must contain %d or %d or %d numbers", n, 2*n-1, 3*n-1);
}